const commonjs = require('@rollup/plugin-commonjs')
const copy = require('rollup-plugin-copy')
const typescript = require('@rollup/plugin-typescript')
const resolve  = require('@rollup/plugin-node-resolve')
const terser = require('@rollup/plugin-terser')
const clear = require('rollup-plugin-clear')
const name = 'index'

module.exports = {
	input: 'src/index.ts',
	output: [
		{
			file: `lib/${name}.js`,
			format: 'cjs'
		}
	],
	plugins: [
		resolve(),
		clear({
			targets: ['lib'],
			watch: true
		}),
		commonjs(),
		typescript({
			declaration: true,
			declarationDir: 'lib/types' // This is inside the 'dist' directory
		}),
		copy({
			targets: [
				{
					src: 'src/template.html',
					dest: 'lib'
				},
				{
					src: 'src/html-config.cjs',
					dest: 'lib'
				}
			]
		}),
		terser()
	],
}
